//
//  QuestionItemCell.swift
//  SwiftDemo
//
//  Created by DYD on 2018/12/5.
//  Copyright © 2018 DYD. All rights reserved.
//

import UIKit

class QuestionItemCell: UICollectionViewCell {
    
    lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 12)
        label.numberOfLines = 0
        return label
    }()
    
    lazy var selectButton: UIButton = {
        let btn = UIButton()
        btn.setImage(UIImage(named: "checkbox_no"), for: UIControlState.normal)
        btn.setImage(UIImage(named: "checkbox_yes"), for: UIControlState.selected)
        btn.isUserInteractionEnabled = false
        return btn
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = CDColor.grayBackgroundColorA
        addSubview(selectButton)
        addSubview(titleLabel)
        selectButton.snp.remakeConstraints { (make) in
            make.left.equalTo(10)
            make.centerY.equalToSuperview()
            make.height.width.equalTo(20)
        }
        titleLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(selectButton.snp.right).offset(5)
            make.centerY.equalTo(selectButton)
            make.right.equalTo(-10)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func config(_ model: QuestionItemModel) {
        titleLabel.text = model.name
        selectButton.isSelected = model.selected
    }
}

